home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / mail / netmail_13.lha / NetMail / Drivers / TurboText.editor < prev    next >
Text File  |  1995-08-11  |  3KB  |  134 lines

  1. /*
  2. ** $VER: TurboText.editor 1.3 (11.8.95)
  3. ** Copyright (c) 1995 Riccardo Solmi
  4. **
  5. */
  6.  
  7. OPTIONS RESULTS
  8. OPTIONS FAILAT 21
  9.  
  10. cmd = 'TURBOTEXT:TTX'
  11. IF ~EXISTS(cmd) THEN DO
  12.    cmd = GetVar('NetMail/TurboTextCmd')
  13.    IF cmd = 0 | ~EXISTS(cmd) THEN DO
  14.       ADDRESS COMMAND 'SetEnv NetMail/TurboTextCmd `Which "TurboText"`'
  15.       cmd = GetVar('NetMail/TurboTextCmd')
  16.       IF cmd = 0 THEN DO
  17.          ADDRESS COMMAND 'SetEnv NetMail/TurboTextCmd `RequestFile Title "Select TurboText command" Noicons`'
  18.          cmd = GetVar('NetMail/TurboTextCmd')
  19.          IF cmd = 0 | ~EXISTS(cmd) THEN RETURN 2
  20.          ADDRESS COMMAND 'Copy QUIET ENV:NetMail/TurboTextCmd ENVARC:NetMail/TurboTextCmd'
  21.       END
  22.    END
  23. END
  24.  
  25. SELECT
  26.    WHEN UPPER(ARG(1)) = 'EDIT' THEN DO
  27.       PARSE ARG , file, port
  28.  
  29.       IF ~SHOW('P', port) | ~ABBREV(port, 'TURBOTEXT') THEN DO
  30.          IF ~SHOW('P', 'TURBOTEXT') THEN DO
  31.             ADDRESS COMMAND
  32.             '"'cmd'" >NIL:'
  33.             'WaitForPort TURBOTEXT0'
  34.             IF RC ~= 0 THEN RETURN 0
  35.             port = 'TURBOTEXT0'
  36.          END
  37.          ELSE DO
  38.             ADDRESS 'TURBOTEXT'
  39.             OpenDoc
  40.             port = RESULT
  41.          END
  42.  
  43.          wininfo = GetVar('NetMail/EditorWin')
  44.          IF wininfo ~= 0 THEN DO
  45.             PARSE VAR wininfo pL pT pW pH .
  46.             ADDRESS VALUE port
  47.             CALL ChangeWindow pL pT pW pH port
  48.          END
  49.       END
  50.       ADDRESS VALUE port
  51.       'SetReadOnly OFF'
  52.       'OpenFile QUIET NAME' file
  53.    END
  54.    WHEN UPPER(ARG(1)) = 'SAVE' THEN DO
  55.       PARSE ARG , port
  56.  
  57.       IF SHOW('P', port) & ABBREV(port, 'TURBOTEXT') THEN DO
  58.          ADDRESS VALUE port
  59.          'SaveFile NOICON NOBACKUP'
  60.       END
  61.    END
  62.    WHEN UPPER(ARG(1)) = 'CLOSE' THEN DO
  63.       PARSE ARG , port
  64.  
  65.       IF SHOW('P', port) & ABBREV(port, 'TURBOTEXT') THEN DO
  66.          ADDRESS VALUE port
  67.          wininfo = GetVar('NetMail/EditorWin')
  68.          PARSE VAR wininfo pL pT pW pH cLTWH
  69.          'GetWindowInfo'
  70.          PARSE VAR RESULT . pL pT pW pH .
  71.          SetVar('NetMail/EditorWin', pL pT pW pH cLTWH)
  72.          'CloseDoc QUIET'
  73.       END
  74.    END
  75. END
  76. RETURN port
  77.  
  78.  
  79. ChangeWindow:
  80. /** $VER: ChangeWindow.ttx 1.0 (23.12.90)
  81.  **
  82.  ** Unlike the MoveWindow and SizeWindow commands this lets you place and
  83.  ** size a window with absolute, not relative, coordinates. ChangeWindow won't
  84.  ** let you go beyond screen boundaries. The window will be moved then
  85.  ** sized as closely to spec as possible.
  86.  **
  87.  ** Written by Art Steinmetz
  88.  ** Modified by Martin Taillefer
  89.  **/
  90.  
  91.  
  92. PARSE ARG left top width height port
  93.  
  94.  
  95.   port = Strip(port,'B')
  96.  
  97.   IF (port ~= "") THEN DO
  98.     ADDRESS VALUE port
  99.   END
  100.  
  101.   GetWindowInfo
  102.   PARSE VAR RESULT icon winLeft winTop winWidth winHeight minWidth minHeight .
  103.   GetScreenInfo
  104.   PARSE VAR RESULT dum dum scrWidth scrHeight .
  105.  
  106.   IF width > scrWidth THEN DO
  107.     width = scrWidth
  108.   END
  109.  
  110.   IF height > scrHeight THEN DO
  111.     Height = scrHeight
  112.   END
  113.  
  114.   IF left + width > scrWidth THEN DO
  115.     left = scrWidth - width
  116.   END
  117.  
  118.   IF top + height > scrHeight THEN DO
  119.     top = scrHeight - height
  120.   END
  121.  
  122.   IF left < 0 THEN DO
  123.     left = 0
  124.   END
  125.  
  126.   IF top < 0 THEN DO
  127.     top = 0
  128.   END
  129.  
  130.   SizeWindow (minWidth - winWidth) (minHeight - winHeight)
  131.   MoveWindow (left - winLeft) (top - winTop)
  132.   SizeWindow (width - minWidth) (height - minHeight)
  133. RETURN
  134.